USE [xRepair]
GO
IF OBJECT_ID('[dbo].[UpdateState]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[UpdateState]
END
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[UpdateState]
		 @ID					INT
		,@StateAbbreviation		NVARCHAR(5)	
		,@StateName				NVARCHAR(255)		
		,@LastUpdatedAt			DATETIME = NULL
		,@LastUpdatedBy			NVARCHAR(50) = NULL
		,@Rowcount				INT = -1 OUTPUT
AS
BEGIN

	SET NOCOUNT ON;

	UPDATE [dbo].[States]
	SET [StateAbbreviation] = @StateAbbreviation
		,[StateName]		= @StateName	
		,[LastUpdatedAt]	= @LastUpdatedAt
		,[LastUpdatedBy]	= @LastUpdatedBy
	WHERE [ID] = @ID

    SELECT @Rowcount = @@ROWCOUNT
END



